// 云函数入口文件
const cloud = require('wx-server-sdk')

// cloud.init({
//   env: "env-4gc5wfa8c81f3f29"
// });
cloud.init();

const db = cloud.database();
const _ = db.command;
// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext();
  const {
    base,
    obj
  } = event
  let collect = db.collection(base)

  try {
    return await collect.add({
      data: obj
    })
  } catch (e) {
    console.error(e)
  }




  // return {
  //   event,
  //   base,
  //   _id,
  //   coltime
  // }
}